package com.party.course.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.party.common.annotation.Log;
import com.party.common.core.controller.BaseController;
import com.party.common.core.domain.AjaxResult;
import com.party.common.enums.BusinessType;
import com.party.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.party.course.domain.DropClassInfo;
import com.party.course.service.IDropClassInfoService;
import com.party.common.core.page.TableDataInfo;

/**
 * 退课信息Controller
 *
 * @author ruoyi
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/course/dropClass" )
public class DropClassInfoController extends BaseController {
    @Autowired
    private IDropClassInfoService dropClassInfoService;

/**
 * 查询退课信息列表
 */
//@RequiresPermissions("course:dropClass:list")
@GetMapping("/list" )
    public TableDataInfo list(DropClassInfo dropClassInfo) {
        startPage();
        List<DropClassInfo> list = dropClassInfoService.findList(dropClassInfo);
        return getDataTable(list);
    }

    /**
     * 导出退课信息列表
     */
    //@RequiresPermissions("course:dropClass:export")
    @Log(title = "退课信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, DropClassInfo dropClassInfo) {
        List<DropClassInfo> list = dropClassInfoService.findList(dropClassInfo);
        ExcelUtil<DropClassInfo> util = new ExcelUtil<DropClassInfo>(DropClassInfo. class);
        util.exportExcel(response, list, "退课信息数据" );
    }

    /**
     * 获取退课信息详细信息
     */
    //@RequiresPermissions("course:dropClass:query")
    @GetMapping(value = "/view/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) String id) {
        return AjaxResult.success(dropClassInfoService.view(id));
    }

    /**
     * 新增退课信息
     */
    //@RequiresPermissions("course:dropClass:add")
    @Log(title = "退课信息" , businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DropClassInfo dropClassInfo) {
        return toAjax(dropClassInfoService.add(dropClassInfo));
    }

    /**
     * 修改退课信息
     */
    //@RequiresPermissions("course:dropClass:edit")
    @Log(title = "退课信息" , businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody DropClassInfo dropClassInfo) {
        return toAjax(dropClassInfoService.updateEntity(dropClassInfo));
    }

    /**
     * 删除退课信息
     */
    //@RequiresPermissions("course:dropClass:remove")
    @Log(title = "退课信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{ids}" )
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(dropClassInfoService.deleteIds(Arrays.asList(ids)));
    }
}
